import 'package:dk_flutter_base/dk_core.dart';
import 'package:flutter/material.dart';

/// 标题及内容Item(左右对齐)
/// [title]:标题
/// [data]:内容
/// [textContentOverflowEllipsis]:文本超出是否显示...(true=显示...)
/// [textLink]:是否为文字链
/// [hasLine]：是否有下划线
/// [urlScheme]:跳转地址
/// [maxLines]:最大行数，如果不限制行数传null
class TitleContentLeftRightAlignItemWidget extends StatelessWidget {
  final String title;
  final String data;
  final bool textContentOverflowEllipsis;
  final bool textLink;
  final bool hasLine;
  final String urlScheme;
  final int maxLines;

  TitleContentLeftRightAlignItemWidget({
    this.title,
    this.data,
    this.textContentOverflowEllipsis = false,
    this.textLink = false,
    this.hasLine = true,
    this.urlScheme,
    this.maxLines = 1,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Column(
        children: <Widget>[
          Container(
            padding: EdgeInsets.only(left: 16, top: 17, right: 16, bottom: 17),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(title,
                    style: TextStyle(color: Color(0xFF666666), fontSize: 14)),
                SizedBox(
                  width: 10.5,
                ),
                Expanded(
                  child: InkWell(
                    onTap: (){
                      if (textLink && stringNotEmpty(urlScheme)) {
                        RouteUtil.goPage(urlScheme);
                      }
                    },
                    child: Text(
                      data,
                      style: TextStyle(
                          color:
                          textLink ? Color(0xFF0096FF) : Color(0xFF333333)),
                      maxLines: maxLines,
                      textAlign: TextAlign.right,
                      overflow: textContentOverflowEllipsis
                          ? TextOverflow.ellipsis
                          : null,
                    ),
                  ),
                ),
              ],
            ),
          ),
          Visibility(
              visible: hasLine,
              child:
                  Divider(height: 0.5, indent: 16, color: Color(0xFFEBEBEB))),
        ],
      ),
    );
  }
}
